package o;

import com.huawei.hmf.orb.exception.ApiNotExistException;
import com.huawei.hmf.orb.exception.GeneralException;
import java.util.ArrayList;
import java.util.List;

public class fhe extends fgo<e> {

    public static class b implements ffc {
        public fic<?> ret;
        public int statusCode = 0;

        public boolean isSuccessful() {
            return this.statusCode == 0;
        }

        public void failure(int i) {
            this.statusCode = -1;
            this.ret = new fic(Integer.valueOf(i));
        }
    }

    public static class e implements ffc {
        public String method;
        public String module;
        public List<fic> param;
        private int returnTypeKind = fhc.CLASS.ordinal();
        public long sequence = -1;
        public String uri;

        fhc getReturnTypeKind() {
            return fhc.values()[this.returnTypeKind];
        }

        void setReturnTypeKind(fhc o_fhc) {
            this.returnTypeKind = o_fhc.ordinal();
        }
    }

    protected void ˋ(e eVar) {
        ffc bVar = new b();
        try {
            bVar = ॱ(ffk.ॱ(this.ˊ.ˏ), eVar);
        } catch (GeneralException e) {
            bVar.failure(e.ˎ);
        } catch (Exception e2) {
            bVar.failure(207135001);
        }
        if (bVar != null) {
            this.ˎ.ˏ(bVar);
        }
    }

    private b ॱ(ffm o_ffm, e eVar) throws GeneralException {
        if (o_ffm == null) {
            throw new GeneralException(207135005);
        } else if ("__constructor__".equals(eVar.method)) {
            return ˎ(o_ffm, eVar);
        } else {
            return ˋ(o_ffm, eVar);
        }
    }

    private b ˎ(ffm o_ffm, e eVar) throws GeneralException {
        b bVar = new b();
        fge ॱ = fge.ॱ(eVar.module);
        if (ॱ == null) {
            throw new GeneralException(207135008);
        }
        ffl ˏ = ॱ.ˏ(eVar.uri);
        if (ˏ == null) {
            ˏ = ffy.ˊ(eVar.uri, eVar.module, eVar.param);
            if (ˏ == null) {
                throw new GeneralException(207135007);
            }
        }
        ˏ(ˏ, eVar);
        bVar.ret = new fic(Long.valueOf(o_ffm.ˋ(ˏ)));
        return bVar;
    }

    private b ˋ(ffm o_ffm, e eVar) throws GeneralException {
        b bVar = new b();
        ffl ˊ = o_ffm.ˊ(Long.valueOf(eVar.sequence));
        if (ˊ == null) {
            throw new GeneralException(207135006);
        }
        Object[] objArr;
        if (eVar.param != null) {
            fic[] o_ficArr = new fic[eVar.param.size()];
            for (int i = 0; i < eVar.param.size(); i++) {
                o_ficArr[i] = eVar.param.get(i);
            }
            objArr = o_ficArr;
        } else {
            objArr = null;
        }
        try {
            Object ॱ = ˊ.ॱ(eVar.method, objArr);
            ˏ(ˊ, eVar);
            if (ॱ != null) {
                fhb ˏ = fhh.ˏ(ॱ.getClass());
                if (ˏ != null) {
                    fey ॱ2 = ˏ.ॱ(ॱ, this.ˎ);
                    if (ॱ2 != null) {
                        o_ffm.ˊ(ॱ2);
                    }
                    return null;
                } else if (eVar.getReturnTypeKind() == fhc.NamedClass) {
                    bVar.ret = new fic(Long.valueOf(o_ffm.ˋ(new fgb(ॱ))));
                    return bVar;
                }
            }
            bVar.ret = new fic(ॱ);
            return bVar;
        } catch (ApiNotExistException e) {
            throw new GeneralException(207135009);
        }
    }

    private void ˏ(ffl o_ffl, e eVar) {
        if (o_ffl.ˊ() != null) {
            fhz ˋ = fho.ˏ().ˋ(eVar.module);
            if (ˋ != null && ˋ.ॱ() != null) {
                fir o_fir = new fir(o_ffl.ˊ());
                o_fir.ॱ(o_ffl.ˋ());
                o_fir.ˊ(eVar.method);
                o_fir.ˏ(o_ffl.ˎ());
                ˋ.ॱ().ॱ(fim.ˊ().ॱ(eVar.module).ˎ(this.ˊ.ˎ).ˎ(o_fir).ˊ());
            }
        }
    }

    public static fgn<b> ˎ(fgd o_fgd, String str, String str2, String str3, Object... objArr) {
        return ˏ(o_fgd, str, str2, str3, fhc.CLASS, objArr);
    }

    public static fgn<b> ˏ(fgd o_fgd, String str, String str2, String str3, fhc o_fhc, Object... objArr) {
        ffc eVar = new e();
        eVar.uri = str2;
        eVar.module = str;
        eVar.method = str3;
        eVar.setReturnTypeKind(o_fhc);
        if (objArr.length > 0) {
            eVar.sequence = ((Long) objArr[0]).longValue();
            if (objArr.length > 1) {
                eVar.param = new ArrayList(objArr.length - 1);
                for (int i = 1; i < objArr.length; i++) {
                    eVar.param.add(new fic(objArr[i]));
                }
            }
        }
        return fgn.ˎ(o_fgd, "InvokeService", eVar, b.class);
    }
}
